package com.qdlc.p2p.biz.executer.impl;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.executer.BaseExecuter;
import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.constant.LogTplNid;
import com.qdlc.p2p.dal.dto.OperationLog;

/**
 * 充值费用
 *
 * @author cx
 * @version 1.0
 * @since 2014-6-5
 */
@Service
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DeductRechargeFeeExecuter extends BaseExecuter {

    @Override
    public void handleAccountWithLog() {
		Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.ACCOUNT_RECHARGE_FEE);
		Global.setTransfer("web_url", WEB_URL);
		accountService.deductUseMoneyAndTotal(super.user.getUserId(), 0L, super.money);
    }

    @Override
    public void addOperateLog() {
        if (null != operator) {
            OperationLog operationLog = new OperationLog(super.user, super.operator, LogTplNid.LINE_RECHARGE_SUCCESS);
            operationLog.setOperationResult("（IP:" + super.operator.getLoginIp() + "）用户名为" + super.operator.getUserName()
                    + "的操作员审核后台充值" + super.user.getUserName() + super.money + "元成功");
            operationLogDao.save(operationLog);
        }
    }
}
